package tw.asap.plus.ui.activity;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;

import com.daimajia.androidanimations.library.Techniques;
import com.daimajia.androidanimations.library.YoYo;

import tw.asap.plus.R;
import tw.asap.plus.ui.BaseActivity;

/**
 * Description:
 * Created:      [15/10/21]
 * Author:       [Yang]
 **/
public class SplashActivity extends BaseActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        hideSystemUI();
        setContentView(R.layout.splash);
        getAppBar().postDelayed(new Runnable() {
            @Override
            public void run() {
//                showSystemUI();
                startActivity(new Intent(SplashActivity.this, MainActivity.class));
                finish();
            }
        }, 1500l);

    }

    @Override
    protected void onResume() {
        super.onResume();
        YoYo.with(Techniques.FadeIn)
                .duration(1000)
                .playOn(findViewById(R.id.splash_app_logo));
    }

    private void hideSystemUI() {
        int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; // hide status bar

        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            getWindow().getDecorView().setSystemUiVisibility(uiFlags);
    }

    private void showSystemUI() {
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            getWindow().getDecorView().setSystemUiVisibility(
                /*View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
        | */View.SYSTEM_UI_FLAG_VISIBLE);
    }
}
